<!DOCTYPE html>
<!--

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

-->
<html lang="en">
  <head>
    <title>Unique Universal Identifiers</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <link rel="stylesheet" href="style/layout.css?0.11.0" type="text/css">

		<style type="text/css">
			p.help input[type="number"] {
				width: 75px;
			}

			table#config.listing {
				clear: both;
			}

			table#config.listing th.countNr {
				width: 75px;
			}
		</style>

    <script src="script/json2.js"></script>
    <script src="script/sha1.js"></script>
    <script src="script/jquery.js?1.4.2"></script>
    <script src="script/jquery.couch.js?0.11.0"></script>
    <script src="script/jquery.dialog.js?0.11.0"></script>
    <script src="script/futon.js?0.11.0"></script>
    <script>
			// UUID-Poll-Object
			var UUIDs=new (function() {
				// Default values for polling
				this.defaults={
					"count": 5
				};

				// Function to return form- or default-count-values
				this.GetCount=function() {
					return ((count=$("form[name='filter'] input=[name='count']").val())?count:this.defaults.count);
				}
				
				// Function to retrieve UUIDs
				this.GetUUIDs=function() {
					$.ajax({
						"url": "/_uuids",
						"data": "count="+this.GetCount(),
						"error": function(jqXHR, textStatus, errorThrown) {
							// Main message
							var msg="Message: An error occured during retrieving _uuids.\n\n";

							// Add Text-Status
							msg+="Text status:\n"+textStatus+"\n\n";

							// Add errorThrown
							msg+="Error thrown:\n"+errorThrown+"\n\n";

							// Display error message
							alert(msg);
						},
						"success": function(data, textStatus, jqXHR) {
							if (data && data["uuids"]) {
								// Content-object
								var $content=$("table#config.listing tbody.content");
								
								// Clear content
								$content.empty();

								// Add UUIDs to content
								$(data["uuids"]).each(function(idx, id) {
									$content.append("<tr><td>"+(idx+1)+"</td><td>"+id+"</td></tr>");
								});
							}
						},
						"dataType": "json"
					});
				}

				$(function() {
					UUIDs.GetUUIDs();
				});
			});
    </script>
  </head>
  <body><div id="wrap">
    <h1>
      <a href="index.html">Overview</a>
      <strong>Unique Universal Identifiers</strong>
    </h1>
    <div id="content">
			<div>
				<p class="help">
					<b>Note:</b><br>
					For plain-text of <i>_uuids</i> click <a href="/_uuids?count=5" target="_blank">here</a>. To change the algorithm used for creating UUIDs watch Configuration-&gt;uuids-&gt;algorithm, and further take an informational look on <a href="http://wiki.apache.org/couchdb/HttpGetUuids#Description" target="_Blank">Apache's CouchDB Wiki, HTTP GET _uuids</a>.
				</p>
				<form name="filter" onsubmit="return false;">
				<p class="help">
					<b>Filter:</b><br>
					<input name="count" type="number" placeholder="5"> <a href="javascript:UUIDs.GetUUIDs();">Retrieve UUIDs</a>
				</p>
				</form>
			</div>
      <table id="config" class="listing" cellspacing="0">
        <caption>Unique Universal Indentifiers</caption>
        <thead><tr>
					<th class="countNr">Count-Nr.</th>
          <th>UUID</th>
        </tr></thead>
        <tbody class="content"></tbody>
      </table>

    </div>
  </div></body>
</html>
